#!/bin/bash

HOST_ADDR=$1

# change host addr
if [ "X${HOST_ADDR}" = "X" ];then
  HOST_ADDR=$(cat cmd/shop/main.go | grep "@host" | awk '{print $3}')
#  HOST_ADDR=$(echo  ${HOST_ADDR} | cut -d ':' -f 1)
else
    sed -i "s/@host .*:8080/@host ${HOST_ADDR}:8080/g" cmd/shop/main.go
fi

swag init -g cmd/shop/main.go  > /dev/null #TODO 不让输出内容
#

echo -e "文档地址：http://${HOST_ADDR}/swagger/index.html"
